<script type="text/javascript">
	var $groupadd_content = $("#groupadd_content");

	$(document).ready(function () {
		var theme = 'fresh';
		$('.field_input').addClass('jqx-input');
		$('.field_input').addClass('field');
		$('.field_input').addClass('jqx-rc-all');

		var grouppost_id = $("#grouppost_id");
		var grouppost_task = $("#grouppost_task");
		var groupadd_save = $("#groupadd_save");
		var groupadd_cancel = $("#groupadd_cancel");
		var grouppost_nama = $("#grouppost_nama");

		groupadd_save.jqxButton({ theme : theme, width : '70px', height : '18px' });
		groupadd_cancel.jqxButton({ width : '70px' , height : '18px' ,theme : theme });

		/* function */
		groupadd_cancel.click(function(){
			$('#mainpanelcontent').empty();
			$('<img src="./images/loader.gif" style="margin:50px auto auto 390px;">').appendTo('#contents');
			$('#mainpanelcontent').load('index.php/c_group/group_load');
		});
		groupadd_save.click(function(){
			var id = "";
			var nama = "";
			var task = "";

			id = grouppost_id.val();
			nama = grouppost_nama.val();
			task = grouppost_task.val();

			if(task == ""){
				task = "create";
			}
			$.ajax({
				type : 'POST',
				url : 'index.php/c_group/group_save',
				data : {
					id : id,
					nama : nama,
					task : task
				},success : function(msg){
					var result = eval(msg);
					switch(result){
						case 1:
							$('#mainpanelcontent').empty();
							$('<img src="./images/loader.gif" style="margin:50px auto auto 390px;">').appendTo('#contents');
							$('#mainpanelcontent').load('index.php/c_group/group_load');
							alert("Data berhasil disimpan");
							break;
						default:
							alert("Data gagal disimpan");
							break;
					}
				}
			});
		});

		<?php
			if(isset($dataDetail)){
		?>
			grouppost_id.val('<?php echo $dataDetail->id; ?>');
			grouppost_nama.val('<?php echo $dataDetail->group_name; ?>');
			grouppost_task.val('update');
		<?php
			}
		?>
	});

</script>
<!-- Begin content -->
<div class="modal_header">
		<span>User Group Form</span>
	</div>
<div class="modal_content">
<div id="groupadd_content">
	<form action="" method="post" >
		<input type="hidden" id="grouppost_id">
		<input type="hidden" id="grouppost_task">
		<p>
			<label>Group Name:</label><br/>
			<input type="text" id="grouppost_nama" class="field_input" style="width:300px"/>
		</p>
		<br/>
		<p>
			<table align="left">
				<tr align="left">
					<td>
						<div id='groupadd_save'>
						<img style='float: left; margin: 0px;' src='./images/icons/save.gif' />
						<div style='float: left; margin-left: 4px;'>Simpan</div>
					</div>
					</td>
					<td>
						<div id='groupadd_cancel'>
						<img style='float: left; margin: 0px;' src='./images/icons/cross.gif' />
						<div style='float: left; margin-left: 4px;'>Cancel</div>
					</div>
					</td>
				</tr>
			</table>
		</p>
		<p>&nbsp;</p>
	</form>
</div>
</div>